﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Linq;

namespace Ruandao.MiniFace
{
    public class Directive : Content
    {
        public string DirectiveType  { get; private set; }
        public Dictionary<string, string> Attributes { get; private set; }
 

        public Directive(Template template, string text)
            : base(template)
        {
            Attributes = new Dictionary<string, string>();
            ParseAttributes(text);
        }

        private void ParseAttributes(string elementText)
        {
            XElement element = XElement.Parse(elementText);
            this.DirectiveType = element.Name.LocalName;

            foreach (var attr in element.Attributes())
            {
                this.Attributes.Add(attr.Name.LocalName, attr.Value);
            }
        }

        public override void Render( TemplateContext templateContext, TextWriter writer)
        {
            //指令无需输出内容。
        }
    }
}
